package com.example.demo.rest;

import com.example.demo.bean.OauthTestInfo;
import com.example.demo.bean.Res;
import com.example.demo.bean.User;
import com.example.demo.repository.OauthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController

public class OauthController {
    @Autowired
    OauthService oauthService;
    @Value("${user.test1}")
    private String test1;

    @GetMapping("oauthinfo")
    public Res<List<OauthTestInfo>> oauthInfo(@RequestParam String env) {
        return Res.success(oauthService.oauthInfo(env));
    }

    @GetMapping("my/account")
    public Res<List<User>> myAccount() {
        Res<List<User>> result = new Res<>();
        List<User> accounts = new ArrayList<>();
        accounts.add(new User(1, "yangyong8@lenovo.com", "test1234"));
        accounts.add(new User(2, "zhangxianwen28@163.com", "1q2w3e4r"));
        result.setData(accounts);
        return result;
    }


}
